package com.ruoyi.qywx.model.vo.mvb;

import cn.hutool.json.JSONUtil;
import com.ruoyi.qywx.entity.Survey;
import com.ruoyi.qywx.entity.SurveyAnswer;
import com.ruoyi.qywx.model.vo.ServeyQuestionVo;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.List;

/**
 * @author : hcl
 * @Date : 2023/9/18 14:28
 */
@Getter
@Setter
public class MvSurveyAnswer {
    //    虚拟uuid缓存
    private String userUUID;
    private String sign;
    //    teamId
    private Long id;
    private List<ServeyQuestionVo> question;

    public SurveyAnswer findUserAnswer(Survey survey) {
        Date now = new Date();
        SurveyAnswer answer = new SurveyAnswer();
        answer.setSurveyId(survey.getId());
        answer.setUuid(userUUID);
        answer.setAnswers(JSONUtil.toJsonStr(question));
        answer.setCreateTime(now);
        answer.setModifyTime(now);
        return answer;
    }
}
